home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Freeware / reportplus / source / f10.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  43.3 KB  |  1,272 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <intuition/intuition.h>
  4. #include <intuition/gadgetclass.h>
  5. #include <libraries/gadtools.h>
  6. #include <dos/dos.h>
  7. #include <dos/dostags.h>
  8. #include <dos/dosextens.h>
  9. #include <dos/exall.h>
  10. #include <dos/datetime.h>
  11. #include <graphics/gfx.h>
  12.  
  13. #include <clib/alib_protos.h>
  14. #include <clib/intuition_protos.h>
  15. #include <clib/graphics_protos.h>
  16. #include <clib/dos_protos.h>
  17. #include <clib/gadtools_protos.h>
  18. #include <clib/exec_protos.h>
  19.  
  20. #include <ctype.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include "rp.h"
  24. #include "files.h"
  25.  
  26. #include <reaction/reaction.h>
  27. #include <gadgets/listbrowser.h>
  28. #include <pragmas/listbrowser_pragmas.h>
  29. #include <gadgets/chooser.h>
  30. #include <pragmas/chooser_pragmas.h>
  31. #include <gadgets/string.h>
  32. #include <pragmas/string_pragmas.h>
  33. #include <gadgets/checkbox.h>
  34. #include <pragmas/checkbox_pragmas.h>
  35. #include <gadgets/layout.h>
  36. #include <pragmas/layout_pragmas.h>
  37. #include <gadgets/button.h>
  38. #include <pragmas/button_pragmas.h>
  39. #include <images/label.h>
  40. #include <pragmas/label_pragmas.h>
  41. #include <proto/label.h>
  42. #include <classes/window.h>
  43. #include <pragmas/window_pragmas.h>
  44.  
  45. MODULE void updatefiles(void);
  46. MODULE void stage1(void);
  47. MODULE void files_work(void);                                 // for stage1()
  48. MODULE void stage2(void);
  49. MODULE ABOOL __inline quickcomp(STRPTR first, STRPTR second); // for stage2()
  50. MODULE void dobuffer(ABOOL item, ULONG whichpen);             // for stage2()
  51. MODULE void stage3(void);
  52. MODULE void stopping(STRPTR status);
  53. MODULE void files_updatelog(void);
  54.  
  55. IMPORT ABOOL                fillwindows;
  56. IMPORT TEXT                 IOBuffer[LONGESTFIELD + 1],
  57.                             aslresult[MEDFIELD + 1];
  58. IMPORT SBYTE                page;
  59. IMPORT ULONG                signal;
  60. IMPORT struct SharedStruct  shared;
  61. IMPORT struct Screen*       ScreenPtr;
  62. IMPORT struct Library     *ButtonBase,
  63.                           *CheckBoxBase,
  64.                           *ChooserBase,
  65.                           *IconBase,
  66.                           *LabelBase,
  67.                           *LayoutBase,
  68.                           *ListBrowserBase,
  69.                           *StringBase,
  70.                           *WindowBase;
  71. IMPORT struct ExAllData*    EADataPtr;
  72. IMPORT struct VisualInfo*   VisualInfoPtr;
  73. IMPORT struct NewGadget     Gadget;
  74. IMPORT struct List          EmptyList;
  75. IMPORT struct Menu*         MenuPtr;
  76. IMPORT Object*              WinObject[FUNCTIONS + 1];
  77.  
  78. AGLOBAL struct Gadget*      files_gadgets[GIDS_10 + 1];
  79.  
  80. MODULE struct List          DirList, FileList;
  81. MODULE struct List          ResultList;
  82. MODULE ABOOL                ResultNodes = FALSE;
  83. MODULE ULONG                status = STATUS_READY;
  84. MODULE struct
  85. {   ULONG show[8]; // anything we want to use GetAttr() with must be ULONG
  86.     ULONG entries;
  87.     ULONG osversion;
  88.     TEXT  path[VLONGFIELD + 1];
  89. } files =
  90. {   TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE,
  91.     0, 5, ""
  92. };
  93. MODULE  BPTR           LogFileHandle       = NULL;
  94. MODULE  TEXT           stringholder1[VLONGFIELD + 1],
  95.                        stringholder2[VLONGFIELD + 1],
  96.                        lockstring[VLONGFIELD + 1];
  97.  
  98. #define OSOPTIONS 5 // counting from 0
  99. MODULE  STRPTR OSOptions[OSOPTIONS + 1] =
  100. {   "OS3.1",
  101.     "OS3.5",
  102.     "OS3.5 & Boing Bag(s)",
  103.     "OS3.9",
  104.     "OS3.9 & Genesis Update",
  105.     "OS3.9 & Boing Bag 1",
  106. };
  107. MODULE struct
  108. {   ULONG red, green, blue, pennumber;
  109. } penn[8] =
  110. {     {0xFFFFFFFF, 0x22222222, 0x22222222, -1}, // red
  111.       {0xFFFFFFFF, 0x88888888, 0x00000000, -1}, // orange
  112.       {0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, -1}, // yellow
  113.       {0x55555555, 0xFFFFFFFF, 0x55555555, -1}, // green
  114.       {0x55555555, 0x55555555, 0xFFFFFFFF, -1}, // blue (obsolete)
  115.       {0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, -1}, // cyan (3rd-party)
  116.       {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, -1}, // white (missing normal)
  117.       {0xFFFFFFFF, 0x99999999, 0x99999999, -1}  // pink (missing optional)
  118. };
  119.  
  120. // from rp.c
  121. IMPORT SBYTE               page;
  122. IMPORT struct Window*      MainWindowPtr;
  123. IMPORT TEXT                weekdaystring[LEN_DATSTRING],
  124.                            datestring[LEN_DATSTRING],
  125.                            timestring[LEN_DATSTRING];
  126.  
  127. AGLOBAL void files1(void)
  128. {   ULONG               i;
  129.     struct List         ChooserList;
  130.     struct ChooserNode* ChooserNodePtr[OSOPTIONS + 1];
  131.     struct Hook         Hook10Struct;
  132.     BOOL                inverse;
  133.  
  134.     if (shared.log)
  135.     {   inverse = FALSE;
  136.     } else
  137.     {   inverse = TRUE;
  138.     }
  139.     if (!shared.pathname[0])
  140.     {   strcpy(shared.pathname, "RAM:Report.txt");
  141.     }
  142.  
  143.     NewList(&ChooserList);
  144.     for (i = 0; i <= OSOPTIONS; i++)
  145.     {   if (!(ChooserNodePtr[i] = (struct ChooserNode *) AllocChooserNode(CNA_Text, OSOptions[i], TAG_DONE)))
  146.         {   rq("Can't allocate chooser node!");
  147.         }
  148.         AddTail(&ChooserList, (struct Node *) ChooserNodePtr[i]);
  149.     } // automatically freed by ReAction at DisposeObject() time
  150.  
  151.     /* Create the window object. */
  152.     lockscreen();
  153.     gadtools();
  154.     InitHook(&Hook10Struct, Hook10Func, NULL);
  155.  
  156.     if (!(WinObject[10] =         NewObject(WINDOW_GetClass(), NULL,
  157.     // window
  158.     WA_PubScreen,                 ScreenPtr,
  159.     WA_ScreenTitle,               "Report+",
  160.     WA_Title,                     "Report+: System Files Report",
  161.     WA_Activate,                  TRUE,
  162.     WA_DepthGadget,               TRUE,
  163.     WA_DragBar,                   TRUE,
  164.     WA_CloseGadget,               TRUE,
  165.     WA_SizeGadget,                TRUE,
  166.     WA_IDCMP,                     IDCMP_RAWKEY,
  167.     WINDOW_IDCMPHook,             &Hook10Struct,
  168.     WINDOW_IDCMPHookBits,         IDCMP_RAWKEY,
  169.     WINDOW_MenuStrip,             MenuPtr,
  170.     WINDOW_Position,              WPOS_CENTERSCREEN,
  171.     WINDOW_ParentGroup,           files_gadgets[GID_10_LY1] =
  172.                                   NewObject(LAYOUT_GetClass(), NULL,
  173.         // root-layout
  174.         LAYOUT_Orientation,       LAYOUT_ORIENT_VERT,
  175.         LAYOUT_SpaceOuter,        TRUE,
  176.         LAYOUT_DeferLayout,       TRUE,
  177.         LAYOUT_AddChild,          NewObject(LAYOUT_GetClass(), NULL,
  178.             // layout
  179.             LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  180.             LAYOUT_SpaceOuter,    TRUE,
  181.             LAYOUT_VertAlignment, LALIGN_CENTER,
  182.             LAYOUT_HorizAlignment,LALIGN_CENTER,
  183.             LAYOUT_BevelStyle,    BVS_FIELD,
  184.             LAYOUT_AddChild,      NewObject(LAYOUT_GetClass(), NULL,
  185.                 // layout
  186.                 LAYOUT_Orientation,   LAYOUT_ORIENT_VERT,
  187.                 LAYOUT_SpaceOuter,    TRUE,
  188.                 LAYOUT_VertAlignment, LALIGN_CENTER,
  189.                 LAYOUT_HorizAlignment,LALIGN_LEFT,
  190.                 LAYOUT_BevelStyle,    BVS_FIELD,
  191.                 LAYOUT_AddImage,
  192.                 NewObject
  193.                 (   LABEL_GetClass(),     NULL,
  194.                     // label
  195.                     LABEL_Text,           "Show:",
  196.                     LABEL_Justification,  LJ_LEFT,
  197.                     TAG_END
  198.                 ),
  199.                 CHILD_WeightedHeight,     0,
  200.                 LAYOUT_AddChild,          files_gadgets[GID_10_CB1] =
  201.                 NewObject
  202.                 (   CHECKBOX_GetClass(),  NULL,
  203.                     // checkbox
  204.                     GA_ID,                GID_10_CB1,
  205.                     GA_RelVerify,         TRUE,
  206.                     CHECKBOX_BackgroundPen, penn[0].pennumber,
  207.                     GA_Text,              "V_ery important",
  208.                     GA_Selected,          (BOOL) files.show[0],
  209.                     TAG_END
  210.                 ),
  211.                 CHILD_WeightedHeight,     0,
  212.                 LAYOUT_AddChild,          files_gadgets[GID_10_CB2] =
  213.                 NewObject(CHECKBOX_GetClass(), NULL,
  214.                     // checkbox
  215.                     GA_ID,                GID_10_CB2,
  216.                     GA_RelVerify,         TRUE,
  217.                     CHECKBOX_BackgroundPen, penn[1].pennumber,
  218.                     GA_Text,              "_Important",
  219.                     GA_Selected,          (BOOL) files.show[1],
  220.                     TAG_END
  221.                 ),
  222.                 CHILD_WeightedHeight,     0,
  223.                 LAYOUT_AddChild,          files_gadgets[GID_10_CB3] =
  224.                 NewObject
  225.                 (   CHECKBOX_GetClass(), NULL,
  226.                     // checkbox
  227.                     GA_ID,                GID_10_CB3,
  228.                     GA_RelVerify,         TRUE,
  229.                     CHECKBOX_BackgroundPen, penn[2].pennumber,
  230.                     GA_Text,              "_Semi-important",
  231.                     GA_Selected,          (BOOL) files.show[2],
  232.                     TAG_END
  233.                 ),
  234.                 CHILD_WeightedHeight,     0,
  235.                 LAYOUT_AddChild,          files_gadgets[GID_10_CB4] =
  236.                 NewObject
  237.                 (   CHECKBOX_GetClass(), NULL,
  238.                     // checkbox
  239.                     GA_ID,                GID_10_CB4,
  240.                     GA_RelVerify,         TRUE,
  241.                     CHECKBOX_BackgroundPen, penn[3].pennumber,
  242.                     GA_Text,              "U_nimportant",
  243.                     GA_Selected,          (BOOL) files.show[3],
  244.                     TAG_END
  245.                 ),
  246.                 CHILD_WeightedHeight,     0,
  247.                 LAYOUT_AddChild,          files_gadgets[GID_10_CB5] =
  248.                 NewObject
  249.                 (   CHECKBOX_GetClass(), NULL,
  250.                     // checkbox
  251.                     GA_ID,                GID_10_CB5,
  252.                     GA_RelVerify,         TRUE,
  253.                     CHECKBOX_BackgroundPen, penn[4].pennumber,
  254.                     GA_Text,              "_Obsolete",
  255.                     GA_Selected,          (BOOL) files.show[4],
  256.                     TAG_END
  257.                 ),
  258.                 CHILD_WeightedHeight,     0,
  259.                 LAYOUT_AddChild,          files_gadgets[GID_10_CB6] =
  260.                 NewObject
  261.                 (   CHECKBOX_GetClass(), NULL,
  262.                     // checkbox
  263.                     GA_ID,                GID_10_CB6,
  264.                     GA_RelVerify,         TRUE,
  265.                     CHECKBOX_BackgroundPen, penn[5].pennumber,
  266.                     GA_Text,              "_3rd-party",
  267.                     GA_Selected,          (BOOL) files.show[5],
  268.                     TAG_END
  269.                 ),
  270.                 CHILD_WeightedHeight,     0,
  271.                 LAYOUT_AddChild,          files_gadgets[GID_10_CB7] =
  272.                 NewObject
  273.                 (   CHECKBOX_GetClass(), NULL,
  274.                     // checkbox
  275.                     GA_ID,                GID_10_CB7,
  276.                     GA_RelVerify,         TRUE,
  277.                     CHECKBOX_BackgroundPen, penn[6].pennumber,
  278.                     GA_Text,              "_Missing normal",
  279.                     GA_Selected,          (BOOL) files.show[6],
  280.                     TAG_END
  281.                 ),
  282.                 CHILD_WeightedHeight,     0,
  283.                 LAYOUT_AddChild,          files_gadgets[GID_10_CB8] =
  284.                 NewObject
  285.                 (   CHECKBOX_GetClass(), NULL,
  286.                     // checkbox
  287.                     GA_ID,                GID_10_CB8,
  288.                     GA_RelVerify,         TRUE,
  289.                     CHECKBOX_BackgroundPen, penn[7].pennumber,
  290.                     GA_Text,              "Missin_g optional",
  291.                     GA_Selected,          (BOOL) files.show[7],
  292.                     TAG_END
  293.                 ),
  294.                 CHILD_WeightedHeight,     0,
  295.                 TAG_END
  296.             ),
  297.             CHILD_WeightedWidth,      0,
  298.             LAYOUT_AddChild,
  299.             NewObject
  300.             (   LAYOUT_GetClass(),    NULL,
  301.                 // layout
  302.                 LAYOUT_Orientation,   LAYOUT_ORIENT_VERT,
  303.                 LAYOUT_SpaceOuter,    TRUE,
  304.                 LAYOUT_VertAlignment, LALIGN_TOP,
  305.                 LAYOUT_HorizAlignment,LALIGN_CENTER,
  306.                 LAYOUT_BevelStyle,    BVS_NONE,
  307.                 LAYOUT_ShrinkWrap,    TRUE,
  308.                 LAYOUT_AddChild,
  309.                 NewObject
  310.                 (   LAYOUT_GetClass(),    NULL,
  311.                     // layout
  312.                     LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  313.                     LAYOUT_SpaceOuter,    TRUE,
  314.                     LAYOUT_VertAlignment, LALIGN_CENTER,
  315.                     LAYOUT_HorizAlignment,LALIGN_CENTER,
  316.                     LAYOUT_BevelStyle,    BVS_FIELD,
  317.                     LAYOUT_AddImage,      NewObject(LABEL_GetClass(), NULL,
  318.                         // label
  319.                         LABEL_Text,       "AmigaOS _Version:",
  320.                         LABEL_Justification,LJ_LEFT,
  321.                         TAG_END
  322.                     ),
  323.                     LAYOUT_AddChild,          files_gadgets[GID_10_CH1] =
  324.                     NewObject
  325.                     (   CHOOSER_GetClass(),   NULL,
  326.                         // chooser
  327.                         GA_ID,                GID_10_CH1,
  328.                         GA_RelVerify,         TRUE,
  329.                         CHOOSER_PopUp,        TRUE,
  330.                         CHOOSER_Labels,       &ChooserList,
  331.                         CHOOSER_Selected,     (WORD) files.osversion,
  332.                         TAG_END
  333.                     ),
  334.                     CHILD_WeightedHeight,     0,
  335.                     TAG_END
  336.                 ),
  337.                 CHILD_WeightedHeight,     0,
  338.                 LAYOUT_AddChild,          NewObject(LAYOUT_GetClass(), NULL,
  339.                     // layout
  340.                     LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  341.                     LAYOUT_SpaceOuter,    TRUE,
  342.                     LAYOUT_VertAlignment, LALIGN_CENTER,
  343.                     LAYOUT_HorizAlignment,LALIGN_CENTER,
  344.                     LAYOUT_BevelStyle,    BVS_FIELD,
  345.                     LAYOUT_ShrinkWrap,    TRUE,
  346.                     LAYOUT_AddChild,      files_gadgets[GID_10_CB9] =
  347.                     NewObject
  348.                     (   CHECKBOX_GetClass(), NULL,
  349.                         // checkbox
  350.                         GA_ID,                GID_10_CB9,
  351.                         GA_RelVerify,         TRUE,
  352.                         GA_Text,              "_Log to:",
  353.                         GA_Selected,          (BOOL) shared.log,
  354.                         TAG_END
  355.                     ),
  356.                     CHILD_WeightedWidth,  0,
  357.                     LAYOUT_AddChild,      files_gadgets[GID_10_ST1] =
  358.                                           NewObject(STRING_GetClass(), NULL,
  359.                         // string        
  360.                         GA_ID,            GID_10_ST1,
  361.                         STRINGA_TextVal,  shared.pathname,
  362.                         STRINGA_MinVisible,20,
  363.                         GA_Disabled,      inverse,
  364.                         TAG_END
  365.                     ),
  366.                     LAYOUT_AddChild,      files_gadgets[GID_10_BU1] =
  367.                     NewObject
  368.                     (   NULL, "button.gadget",
  369.                         // button
  370.                         GA_ID,            GID_10_BU1,
  371.                         GA_RelVerify,     TRUE,
  372.                         BUTTON_AutoButton,BAG_POPFILE,
  373.                         GA_Disabled,      inverse,
  374.                         TAG_END
  375.                     ),
  376.                     CHILD_WeightedWidth,  0,
  377.                     TAG_END
  378.                 ),
  379.                 CHILD_WeightedHeight,     0,
  380.                 LAYOUT_AddChild,          files_gadgets[GID_10_ST2] =
  381.                 NewObject
  382.                 (   STRING_GetClass(),    NULL,
  383.                     GA_ReadOnly,          TRUE,
  384.                     GA_ID,                GID_10_ST2,
  385.                     STRINGA_TextVal,      "Ready.",
  386.                     TAG_END
  387.                 ),
  388.                 LAYOUT_AddChild,
  389.                 NewObject
  390.                 (   LAYOUT_GetClass(),    NULL,
  391.                     // layout
  392.                     LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  393.                     LAYOUT_SpaceOuter,    TRUE,
  394.                     LAYOUT_VertAlignment, LALIGN_CENTER,
  395.                     LAYOUT_HorizAlignment,LALIGN_CENTER,
  396.                     LAYOUT_BevelStyle,    BVS_FIELD,
  397.                     LAYOUT_AddChild,      files_gadgets[GID_10_BU2] =
  398.                     NewObject
  399.                     (   NULL,             "button.gadget",
  400.                         // button
  401.                         GA_ID,            GID_10_BU2,
  402.                         GA_RelVerify,     TRUE,
  403.                         GA_Text,          "_Update",
  404.                         TAG_END
  405.                     ),
  406.                     CHILD_WeightedWidth,  50,
  407.                     LAYOUT_AddChild,      files_gadgets[GID_10_BU3] =
  408.                     NewObject
  409.                     (   NULL,             "button.gadget",
  410.                         // button
  411.                         GA_ID,            GID_10_BU3,
  412.                         GA_RelVerify,     TRUE,
  413.                         GA_Text,          "Stop",
  414.                         GA_Disabled,      TRUE,
  415.                         TAG_END
  416.                     ),
  417.                     CHILD_WeightedWidth,  50,
  418.                     TAG_END
  419.                 ),
  420.                 CHILD_WeightedHeight,     0,
  421.                 TAG_END
  422.             ),
  423.             CHILD_WeightedHeight,         0,
  424.             TAG_END
  425.         ),
  426.         CHILD_WeightedHeight,         0,
  427.         LAYOUT_AddChild,              files_gadgets[GID_10_LB1] =
  428.         NewObject
  429.         (   LISTBROWSER_GetClass(),   NULL,
  430.             GA_ID,                    GID_10_LB1,
  431.             GA_ReadOnly,              TRUE,
  432.             GA_TextAttr,              Gadget.ng_TextAttr,
  433.             LISTBROWSER_ScrollRaster, TRUE,
  434.             LISTBROWSER_Labels,       (ULONG) &EmptyList,
  435.             LISTBROWSER_MinVisible,   12,
  436.             TAG_END
  437.         ),
  438.         CHILD_WeightedHeight,         100,
  439.         LAYOUT_AddChild,              files_gadgets[GID_10_BU4] =
  440.         NewObject
  441.         (   NULL,                     "button.gadget",
  442.             // button
  443.             GA_ID,                    GID_10_BU4,
  444.             GA_RelVerify,             TRUE,
  445.             GA_Text,                  "Menu",
  446.             TAG_END),
  447.         CHILD_WeightedHeight,         0,
  448.         TAG_END
  449.     ),
  450.     TAG_END
  451.     )))
  452.     {   rq("Can't create ReAction object(s)!");
  453.     }
  454.     unlockscreen();
  455.     openwindow();
  456.     loop();
  457.     if (ResultNodes)
  458.     {   clearreactionlist(&ResultList);
  459.         ResultNodes = FALSE;
  460.     }
  461.     closewindow();
  462. }
  463.  
  464. MODULE void updatefiles(void)
  465. {   ULONG  i;
  466.     STRPTR stringptr;
  467.  
  468.     /* Most gadgets are ghosted during the operation. Then their ghosting
  469.     status returns to normal (not necessarily unghosted).
  470.  
  471.     Disable the `Menu' (BU), `Update' (BU). `Log to file?' (CB),
  472.     `Pathname' (ST), `...' (BU), `Show' (CB), `OS version' (MX), `Stop'
  473.     (BU) gadgets. Status (TE) is changed.
  474.  
  475.         0: Gadget handling.
  476.         1: Set up lists, do the directory examination.
  477.            (For each `source' directory in the `queue', before doing it
  478.            we check for a break. `Break opportunity 1'.)
  479.     At this point we have an empty DirList, and a full FileList, and an
  480.     empty ResultList.
  481.         2: Create the ResultList.
  482.            (For each `source' file in the `queue', before doing it we
  483.            check for a break. `Break opportunity 2'.)
  484.         3: Show results.
  485.  
  486.        DirList: an Exec list of directories found, awaiting examination.
  487.       FileList: an Exec list of files found, awaiting processing.
  488.     ResultList: a listbrowser list of files found, for display.
  489.  
  490.     Apparently the way strings work is that you get told an address where
  491.     the string is stored. This is apparently a pointer into system memory;
  492.     it doesn't need explicit allocation/deallocation by our appliprog. */
  493.  
  494.     if (!(GetAttr
  495.     (   STRINGA_TextVal, files_gadgets[GID_10_ST1], (ULONG *) &stringptr
  496.     )))
  497.     {   rq("Unsupported inquiry!"); // should never happen
  498.     }
  499.     strcpy(shared.output, stringptr);
  500.  
  501.     SetGadgetAttrs // `Menu'
  502.     (   files_gadgets[GID_10_BU4], MainWindowPtr, NULL,
  503.         GA_Disabled, TRUE,
  504.         TAG_END
  505.     );
  506.     SetGadgetAttrs // `Update'
  507.     (   files_gadgets[GID_10_BU2], MainWindowPtr, NULL,
  508.         GA_Disabled, TRUE,
  509.         TAG_END
  510.     );
  511.     SetGadgetAttrs // `Log to file?' (checkbox)
  512.     (   files_gadgets[GID_10_CB9], MainWindowPtr, NULL,
  513.         GA_Disabled, TRUE,
  514.         TAG_END
  515.     );
  516.     /* For some reason, we need to explicitly refresh the checkbox gadget
  517.     visuals here */
  518.     RefreshGadgets((struct Gadget *) files_gadgets[GID_10_CB9], MainWindowPtr, NULL);
  519.     SetGadgetAttrs // `Log to file:' (string)
  520.     (   files_gadgets[GID_10_ST1], MainWindowPtr, NULL,
  521.         GA_Disabled, TRUE,
  522.         TAG_END
  523.     );
  524.     SetGadgetAttrs // `Log to file:' (ASL button)
  525.     (   files_gadgets[GID_10_BU1], MainWindowPtr, NULL,
  526.         GA_Disabled, TRUE,
  527.         TAG_END
  528.     );
  529.     SetGadgetAttrs // `AmigaOS Version:'
  530.     (   files_gadgets[GID_10_CH1], MainWindowPtr, NULL,
  531.         GA_Disabled, TRUE,
  532.         TAG_END
  533.     );
  534.     for (i = 0; i <= 7; i++)
  535.     {   SetGadgetAttrs // `Show:'
  536.         (   files_gadgets[GID_10_CB1 + i], MainWindowPtr, NULL,
  537.             GA_Disabled, TRUE,
  538.             TAG_END
  539.         );
  540.         /* For some reason, we need to explicitly refresh the checkbox gadget
  541.         visuals here */
  542.         RefreshGadgets((struct Gadget *) files_gadgets[GID_10_CB1 + i], MainWindowPtr, NULL);
  543.     }
  544.     SetGadgetAttrs // `Stop'
  545.     (   files_gadgets[GID_10_BU3], MainWindowPtr, NULL,
  546.         GA_Disabled, FALSE,
  547.         TAG_END
  548.     );
  549.     SetGadgetAttrs // `Status'
  550.     (   files_gadgets[GID_10_ST2], MainWindowPtr, NULL,
  551.         STRINGA_TextVal, "Busy...",
  552.         TAG_END
  553.     );
  554.     SetGadgetAttrs
  555.     (   files_gadgets[GID_10_LB1], MainWindowPtr, NULL,
  556.         LISTBROWSER_Labels, NULL,
  557.         TAG_END
  558.     );
  559.     SetGadgetAttrs
  560.     (   files_gadgets[GID_10_LB1], MainWindowPtr, NULL,
  561.         LISTBROWSER_Labels, (ULONG) &EmptyList,
  562.         TAG_END
  563.     );
  564.     if (ResultNodes)
  565.     {   clearreactionlist(&ResultList);
  566.         ResultNodes = FALSE;
  567.     }
  568.  
  569.     status = STATUS_BUSY;
  570.     stage1();
  571.     if (status == STATUS_BUSY)
  572.     {   stage2();
  573.     }
  574.     FreeNameNodes(&FileList);
  575.     if (status == STATUS_BUSY)
  576.     {   stage3();
  577.     }
  578.     status = STATUS_READY;
  579.  
  580.     SetGadgetAttrs // `Menu'
  581.     (   files_gadgets[GID_10_BU4], MainWindowPtr, NULL,
  582.         GA_Disabled, FALSE,
  583.         TAG_END
  584.     );
  585.     SetGadgetAttrs // `Update'
  586.     (   files_gadgets[GID_10_BU2], MainWindowPtr, NULL,
  587.         GA_Disabled, FALSE,
  588.         TAG_END
  589.     );
  590.     SetGadgetAttrs // `Log to?' (checkbox)
  591.     (   files_gadgets[GID_10_CB9], MainWindowPtr, NULL,
  592.         GA_Disabled, FALSE,
  593.         TAG_END
  594.     );
  595.     /* For some reason, we need to explicitly refresh the checkbox gadget
  596.     visuals here */
  597.     RefreshGadgets((struct Gadget *) files_gadgets[GID_10_CB9], MainWindowPtr, NULL);
  598.     files_updatelog();
  599.     SetGadgetAttrs // `AmigaOS Version'
  600.     (   files_gadgets[GID_10_CH1], MainWindowPtr, NULL,
  601.         GA_Disabled, FALSE,
  602.         TAG_END
  603.     );
  604.     for (i = 0; i <= 7; i++)
  605.     {   SetGadgetAttrs // `Show'
  606.         (   files_gadgets[GID_10_CB1 + i], MainWindowPtr, NULL,
  607.             GA_Disabled, FALSE,
  608.             TAG_END
  609.         );
  610.         /* For some reason, we need to explicitly refresh the checkbox gadget
  611.         visuals here */
  612.         RefreshGadgets((struct Gadget *) files_gadgets[GID_10_CB1 + i], MainWindowPtr, NULL);
  613.     }
  614.     SetGadgetAttrs // `Stop'
  615.     (   files_gadgets[GID_10_BU3], MainWindowPtr, NULL,
  616.         GA_Disabled, TRUE,
  617.         TAG_END
  618.     );
  619.     SetGadgetAttrs // `Status'
  620.     (   files_gadgets[GID_10_ST2], MainWindowPtr, NULL,
  621.         STRINGA_TextVal, "Ready.",
  622.         TAG_END
  623.     );
  624. }
  625.  
  626. MODULE void stage1(void)
  627. {   struct NameNode* NodePtr;
  628.  
  629.     NewList(&FileList);
  630.     NewList(&DirList);
  631.     NewList(&ResultList);
  632.     AddNameToTail(&DirList, "");
  633.     // pop all the directories from the work stack, and send them one
  634.     // at a time to files_work() for processing.
  635.     while ((DirList.lh_Head)->ln_Succ) // while the list is non-empty
  636.     {   if (ra_checkbreak() == 1) // we don't yet support completely quitting
  637.         {   status = STATUS_STOPPING;
  638.             stopping("Stopping...");
  639.             break;
  640.         }
  641.  
  642.         /* remove the dir-node from the list, copy its path to
  643.            stringholder1, call files_work, then free the dir-node. */
  644.  
  645.         if (!(NodePtr = (struct NameNode *) RemTail(&DirList)))
  646.         {   rq("RemTail() failed (list is empty!)"); // this should never happen
  647.         }
  648.         strcpy(stringholder1, NodePtr->nn_Data);
  649.         files_work();
  650.         FreeMem(NodePtr, sizeof(struct NameNode));
  651.     }
  652.     FreeNameNodes(&DirList); // Not required unless stopping early (although harmless).
  653. }
  654.  
  655. MODULE void stage2(void)
  656. {   ABOOL            matched, infomatched;
  657.     ULONG            i, length;
  658.     UBYTE            theversion;
  659.     struct NameNode* NodePtr;
  660.  
  661.     // Everything is already allocated. Don't deallocate in this routine.
  662.  
  663.     if (shared.log)
  664.     {   if (!(LogFileHandle = (BPTR) Open(shared.output, MODE_READWRITE)))
  665.             rq("Can't open file for appending!");
  666.         Seek(LogFileHandle, 0, OFFSET_END);
  667.     }
  668.  
  669.     // Now we have the list of files
  670.     getdate();
  671.     strcpy(IOBuffer, "AmigaOS 3.");
  672.     if (files.osversion == 0)
  673.     {   theversion = 31;
  674.         strcat(IOBuffer, "1");
  675.     } elif (files.osversion == 1)
  676.     {   theversion = 35;
  677.         strcat(IOBuffer, "5");
  678.     } elif (files.osversion == 2)
  679.     {   theversion = 36;
  680.         strcat(IOBuffer, "5 + BB1/2");
  681.     } elif (files.osversion == 3)
  682.     {   theversion = 39;
  683.         strcat(IOBuffer, "9");
  684.     } elif (files.osversion == 5)
  685.     {   theversion = 41;
  686.         strcat(IOBuffer, "9 + BB1");
  687.     } else
  688.     {   // assert(files.osversion == 4);
  689.         theversion = 40;
  690.         strcat(IOBuffer, "9 + Genesis Update");
  691.     }
  692.     strcat(IOBuffer, " system files at ");
  693.     strcat(IOBuffer, timestring);
  694.     strcat(IOBuffer, " on ");
  695.     strcat(IOBuffer, weekdaystring);
  696.     strcat(IOBuffer, " ");
  697.     strcat(IOBuffer, datestring);
  698.     strcat(IOBuffer, ":\n"); // another \n is inserted automatically by dobuffer()
  699.     dobuffer(FALSE, 0);
  700.  
  701.     for (i = 0; i <= FILES; i++)
  702.         os[i].matched = os[i].infomatched = FALSE;
  703.  
  704.     /* status is always STATUS_BUSY at this point, because this function is
  705.     not called otherwise. */
  706.  
  707.     while ((FileList.lh_Head)->ln_Succ) // while the list is non-empty
  708.     {   if (ra_checkbreak() == 1)
  709.         {   status = STATUS_STOPPING;
  710.             stopping("Stopping...");
  711.             strcpy(IOBuffer, "Aborted by user!");
  712.             dobuffer(FALSE, 0);
  713.             break;
  714.         }
  715.         // assert(status != STATUS_STOPPING);
  716.  
  717.         if (!(NodePtr = (struct NameNode *) RemTail(&FileList)))
  718.         {   rq("RemTail() failed (list is empty!)"); // should never happen
  719.         }
  720.         strcpy(stringholder1, NodePtr->nn_Data);
  721.         length = strlen(stringholder1);
  722.         FreeMem(NodePtr, sizeof(struct NameNode));
  723.  
  724.         // now we have removed the file from the `queue', and copied its
  725.         // name into stringholder1. Now we check it against each system
  726.         // file.
  727.  
  728.         matched = infomatched = FALSE;
  729.         for (i = 0; i <= FILES; i++)
  730.         {   if (os[i].version <= theversion)
  731.             {   if (!matched && quickcomp(stringholder1, os[i].pathname))
  732.                 {   // we have a match
  733.  
  734.                     strcpy(IOBuffer, os[i].pathname);
  735.                     matched = os[i].matched = TRUE;
  736.  
  737.                     // check whether file is obsoleted by OS3.9 or by Genesis Update
  738.                     if
  739.                     (   (theversion >= 39 && (os[i].flags & NOT39))
  740.                      || (theversion >= 40 && (os[i].flags & NOT39UPDATE))
  741.                      || (os[i].flags & CODE_BLUE)
  742.                     )
  743.                     {   dobuffer(TRUE, 12);
  744.                     } elif (os[i].flags & CODE_RED)
  745.                     {   dobuffer(TRUE,  8);
  746.                     } elif (os[i].flags & CODE_ORANGE)
  747.                     {   dobuffer(TRUE,  9);
  748.                     } elif (os[i].flags & CODE_YELLOW)
  749.                     {   dobuffer(TRUE, 10);
  750.                     } else
  751.                     {   // assert(os[i].flags & CODE_GREEN);
  752.                         dobuffer(TRUE, 11);
  753.                 }   }
  754.                 elif
  755.                 (   !infomatched
  756.                  && (os[i].flags & INFO)
  757.                  && (stringholder1[length - 5] == '.')
  758.                 ) // we probably have a match, let's confirm
  759.                 {   strcpy(IOBuffer, os[i].pathname);
  760.                     strcat(IOBuffer, ".info");
  761.                     if (quickcomp(stringholder1, IOBuffer))
  762.                     {   // we have a match
  763.                         infomatched = os[i].infomatched = TRUE;
  764.  
  765.                         // check whether file is obsoleted by OS3.9 or by Genesis Update
  766.                         if
  767.                         (   (theversion >= 39 && (os[i].flags & NOT39))
  768.                          || (theversion >= 40 && (os[i].flags & NOT39UPDATE))
  769.                         )
  770.                         {   dobuffer(TRUE, 12); // obsolete
  771.                         } else
  772.                         {   dobuffer(TRUE, 11); // automatic .info files are always green
  773.         }   }   }   }   }
  774.         if (!matched && !infomatched) // third-party (cyan)
  775.         {   strcpy(IOBuffer, stringholder1);
  776.             dobuffer(TRUE, 13);
  777.     }   }
  778.  
  779.     // missing files
  780.     if (status == STATUS_BUSY)
  781.     {   for (i = 0; i <= FILES; i++)
  782.         {   if
  783.             (   !(os[i].flags & CODE_BLUE) // missing obsolete are NEVER shown
  784.              && os[i].version <= theversion
  785.              && (theversion < 39 || !(os[i].flags & NOT39))
  786.              && (theversion < 40 || !(os[i].flags & NOT39UPDATE))
  787.             )
  788.             if (files.show[6] && !(os[i].flags & OPTIONAL))
  789.             {   if (!os[i].matched)
  790.                 {   strcpy(IOBuffer, os[i].pathname); // white (missing normal)
  791.                     dobuffer(TRUE, 14);
  792.                 }
  793.                 if ((os[i].flags & INFO) && !os[i].infomatched)
  794.                 {   strcpy(IOBuffer, os[i].pathname); // white (missing normal)
  795.                     strcat(IOBuffer, ".info");
  796.                     dobuffer(TRUE, 14);
  797.             }   }
  798.             elif (files.show[7] &&  (os[i].flags & OPTIONAL))
  799.             {   if (!os[i].matched)
  800.                 {   strcpy(IOBuffer, os[i].pathname); // pink (missing optional)
  801.                     dobuffer(TRUE, 15);
  802.                 }
  803.                 if ((os[i].flags & INFO) && !os[i].infomatched)
  804.                 {   strcpy(IOBuffer, os[i].pathname); // pink (missing optional)
  805.                     strcat(IOBuffer, ".info");
  806.                     dobuffer(TRUE, 15);
  807.     }   }   }   }
  808.  
  809.     if (LogFileHandle)
  810.     {   Close(LogFileHandle); // Close() doesn't return an error code
  811.         LogFileHandle = NULL;
  812. }   }
  813.  
  814. MODULE void stage3(void)
  815. {   /* pens go thusly:
  816.     0 red
  817.     1 orange
  818.     2 yellow
  819.     3 green
  820.     4 blue
  821.     5 cyan
  822.     6 white
  823.     7 pink */
  824.  
  825.     stopping("Ready.");
  826.  
  827.     SetGadgetAttrs
  828.     (   files_gadgets[GID_10_LB1], MainWindowPtr, NULL,
  829.         LISTBROWSER_Labels, NULL,
  830.         TAG_END
  831.     );
  832.     SetGadgetAttrs
  833.     (   files_gadgets[GID_10_LB1], MainWindowPtr, NULL,
  834.         LISTBROWSER_Labels, (ULONG) &ResultList,
  835.         TAG_END
  836.     );
  837. }
  838.  
  839. /* FileNamePtr[]: each of these is a pointer to the allocated memory
  840. area holding the pathname of that file found (excepting "SYS:" portion).
  841. FileNamesAllocated = number of elements of FileNamePtr[]. Or, another way
  842. to think of it, the number of files on the SYS: partition. Element 0 of
  843. the array is not used. */
  844.  
  845. MODULE void files_work(void)
  846. {   BOOL                 more; // BOOL, not ABOOL
  847.     BPTR                 DirHandle; // = NULL;
  848.     struct ExAllControl* eac;       // = NULL;
  849.     struct ExAllData*    ead;
  850.  
  851.     /* Service routine for stage1(). Each call of this routine
  852.     handles one directory from the work stack. This routine is the one
  853.     that actually makes the DOS calls. It pushes any subdirectories
  854.     found onto the stack.
  855.  
  856.     stringholder1 contains the pathname of the directory to examine
  857.         (without "SYS:").
  858.     lockstring contains the pathname of the directory to examine
  859.         (with "SYS:").
  860.     stringholder2 will contain the pathname of each file/dir found
  861.         (with "SYS:"). */
  862.  
  863.     strcpy(lockstring, "SYS:");
  864.     strcat(lockstring, stringholder1);
  865.  
  866.     if (!(DirHandle = (BPTR) Lock(lockstring, ACCESS_READ)))
  867.     {   // Printf("Can't lock %s!\n", lockstring);
  868.         rq("Can't lock directory!");
  869.     }
  870.     if (!(eac = AllocDosObject(DOS_EXALLCONTROL, NULL)))
  871.     {   UnLock(DirHandle);
  872.         DirHandle = NULL;
  873.         rq("Can't allocate DOS object!");
  874.     }
  875.  
  876.     eac->eac_LastKey = 0;
  877.     do
  878.     {   more = ExAll(DirHandle, (struct ExAllData *) EADataPtr, 4096, ED_SIZE, eac);
  879.         if ((!more) && (IoErr() != ERROR_NO_MORE_ENTRIES))
  880.         {   FreeDosObject(DOS_EXALLCONTROL, eac);
  881.             eac = NULL;
  882.             UnLock(DirHandle);
  883.             DirHandle = NULL;
  884.             rq("Can't examine path!"); /* ExAll() failed abnormally */
  885.         }
  886.         if (eac->eac_Entries == 0)
  887.         {   ; /* ExAll() failed normally with no entries */
  888.             continue; /* more is USUALLY zero */
  889.         }
  890.         ead = (struct ExAllData *) EADataPtr;
  891.  
  892.         do
  893.         {   /* use ead here */
  894.  
  895.             strcpy(stringholder2, lockstring);
  896.             if (!AddPart(stringholder2, ead->ed_Name, VLONGFIELD))
  897.             {   FreeDosObject(DOS_EXALLCONTROL, eac);
  898.                 eac = NULL;
  899.                 UnLock(DirHandle);
  900.                 DirHandle = NULL;
  901.                 rq("Can't add filename/dirname to pathname!");
  902.             }
  903.             if (ead->ed_Type == 2) /* +2 is dir, +3 is softlink, -3 is file */
  904.             {   AddNameToTail(&DirList,  &(stringholder2[4]));
  905.             } elif (ead->ed_Type == -3) // if it's a file
  906.             {   AddNameToTail(&FileList, &(stringholder2[4]));
  907.             }
  908.  
  909.             /* get next ead */
  910.             ead = ead->ed_Next;
  911.         } while(ead);
  912.     } while(more);
  913.  
  914.     FreeDosObject(DOS_EXALLCONTROL, eac);
  915.     eac = NULL;
  916.     UnLock(DirHandle);
  917.     DirHandle = NULL;
  918. }
  919.  
  920. MODULE ABOOL __inline quickcomp(STRPTR first, STRPTR second)
  921. {   ULONG i = 0;
  922.  
  923.     while (*(first + i))
  924.     {   if (*(first + i)      != *(second + i)
  925.         &&  *(first + i)      != *(second + i) + 32
  926.         &&  *(first + i) + 32 != *(second + i)
  927.         &&  *(first + i) + 32 != *(second + i) + 32
  928.         )
  929.             return FALSE;
  930.         i++;
  931.     }
  932.     return TRUE;
  933. }
  934.  
  935. MODULE void dobuffer(ABOOL item, ULONG whichpen)
  936. {   struct Node* ListBrowserNodePtr;
  937.     TEXT         codestring[VLONGFIELD + 1];
  938.  
  939.     /* Service routine for stage2(). */
  940.  
  941.     if (item && files.show[whichpen - 8])
  942.     {   if (!(ListBrowserNodePtr = AllocListBrowserNode
  943.         (   1,              // columns,
  944.             LBNA_Column,    0,
  945.             LBNA_Flags,     LBFLG_CUSTOMPENS,
  946.             LBNCA_FGPen,    BLACK,
  947.             LBNCA_BGPen,    penn[whichpen - 8].pennumber,
  948.             LBNCA_CopyText, TRUE,
  949.             LBNCA_Text,     IOBuffer,
  950.             TAG_END))
  951.         )
  952.         {   rq("Can't create ReAction listbrowser.gadget node(s)!");
  953.         }
  954.         AddTail(&ResultList, ListBrowserNodePtr); // AddTail() has no return code
  955.         ResultNodes = TRUE;
  956.     }
  957.     if (shared.log)
  958.     {   if (!item)
  959.         {   strcpy(codestring, IOBuffer);
  960.             strcat(codestring, "\n");
  961.             if (Write(LogFileHandle, codestring, strlen(codestring)) == -1)
  962.             {   rq("Can't append to file!");
  963.         }   }
  964.         elif (files.show[whichpen - 8])
  965.         {   switch(whichpen)
  966.             {
  967.             case 8:
  968.                 strcpy(codestring, "! "); // red
  969.             break;
  970.             case 9:
  971.                 strcpy(codestring, "@ "); // orange
  972.             break;
  973.             case 10:
  974.                 strcpy(codestring, "# "); // yellow
  975.             break;
  976.             case 11:
  977.                 strcpy(codestring, "$ "); // green
  978.             break;
  979.             case 12:
  980.                 strcpy(codestring, "% "); // blue (obsolete)
  981.             break;
  982.             case 13:
  983.                 strcpy(codestring, "& "); // cyan (3rd-party)
  984.             break;
  985.             case 14:
  986.                 strcpy(codestring, "- "); // white (missing normal)
  987.             break;
  988.             case 15:
  989.                 strcpy(codestring, "= "); // pink (missing optional)
  990.             break;
  991.             default:
  992.                 // assert(0);
  993.             break;
  994.             }
  995.             strcat(codestring, IOBuffer);
  996.             strcat(codestring, "\n");
  997.             if (Write(LogFileHandle, codestring, strlen(codestring)) == -1)
  998.             {   rq("Can't append to file!");
  999. }   }   }   }
  1000.  
  1001. AGLOBAL void files_init(void)
  1002. {   ULONG i;
  1003.  
  1004.     lockscreen();
  1005.     for (i = 0; i <= 7; i++)
  1006.     {   penn[i].pennumber = FindColor
  1007.         (   ScreenPtr->ViewPort.ColorMap,
  1008.             penn[i].red,
  1009.             penn[i].green,
  1010.             penn[i].blue,
  1011.             -1
  1012.         );
  1013.     }
  1014.     unlockscreen();
  1015.     if (!(shared.output[0]))
  1016.     {   strcpy(shared.output, "RAM:Report.txt");
  1017. }   }
  1018.  
  1019. AGLOBAL void files_exit(void)
  1020. {   // The window should be closed before calling this.
  1021.  
  1022.     if (ResultNodes)
  1023.     {   clearreactionlist(&ResultList);
  1024.         ResultNodes = FALSE;
  1025.     }
  1026.     if (LogFileHandle)
  1027.     {   Close(LogFileHandle); // Close() doesn't return an error code
  1028.         LogFileHandle = NULL;
  1029. }   }
  1030.  
  1031. AGLOBAL void files_die(void)
  1032. {   ULONG i;
  1033.  
  1034.     IOBuffer[7] = files.osversion;
  1035.  
  1036.     for (i = 0; i <= 7; i++)
  1037.     {   IOBuffer[8 + i] = files.show[i];
  1038. }   }
  1039.  
  1040. AGLOBAL void files_config(void)
  1041. {   ULONG i;
  1042.  
  1043.     files.osversion = IOBuffer[7];
  1044.  
  1045.     for (i = 0; i <= 7; i++)
  1046.     {   files.show[i] = IOBuffer[8 + i];
  1047. }   }
  1048.  
  1049. AGLOBAL void files_loop(ULONG gid)
  1050. {   STRPTR stringptr;
  1051.  
  1052.     switch (gid)
  1053.     {
  1054.     case GID_10_CH1:
  1055.         if (!(GetAttr
  1056.         (   CHOOSER_Selected, files_gadgets[GID_10_CH1], (ULONG *) &files.osversion
  1057.         )))
  1058.         {   rq("Unsupported inquiry!"); // should never happen
  1059.         }
  1060.     break;
  1061.     case GID_10_CB1:
  1062.         if (!(GetAttr
  1063.         (   GA_Selected, files_gadgets[GID_10_CB1], (ULONG *) &files.show[0]
  1064.         )))
  1065.         {   rq("Unsupported inquiry!"); // should never happen
  1066.         }
  1067.     break;
  1068.     case GID_10_CB2:
  1069.         if (!(GetAttr
  1070.         (   GA_Selected, files_gadgets[GID_10_CB2], (ULONG *) &(files.show[1])
  1071.         )))
  1072.         {   rq("Unsupported inquiry!"); // should never happen
  1073.         }
  1074.     break;
  1075.     case GID_10_CB3:
  1076.         if (!(GetAttr
  1077.         (   GA_Selected, files_gadgets[GID_10_CB3], (ULONG *) &files.show[2]
  1078.         )))
  1079.         {   rq("Unsupported inquiry!"); // should never happen
  1080.         }
  1081.     break;
  1082.     case GID_10_CB4:
  1083.         if (!(GetAttr
  1084.         (   GA_Selected, files_gadgets[GID_10_CB4], (ULONG *) &files.show[3]
  1085.         )))                                                                    
  1086.         {   rq("Unsupported inquiry!"); // should never happen
  1087.         }
  1088.     break;
  1089.     case GID_10_CB5:
  1090.         if (!(GetAttr
  1091.         (   GA_Selected, files_gadgets[GID_10_CB5], (ULONG *) &files.show[4]
  1092.         )))
  1093.         {   rq("Unsupported inquiry!"); // should never happen
  1094.         }
  1095.     break;
  1096.     case GID_10_CB6:
  1097.         if (!(GetAttr
  1098.         (   GA_Selected, files_gadgets[GID_10_CB6], (ULONG *) &files.show[5]
  1099.         )))
  1100.         {   rq("Unsupported inquiry!"); // should never happen
  1101.         }
  1102.     break;
  1103.     case GID_10_CB7:
  1104.         if (!(GetAttr
  1105.         (   GA_Selected, files_gadgets[GID_10_CB7], (ULONG *) &files.show[6]
  1106.         )))
  1107.         {   rq("Unsupported inquiry!"); // should never happen
  1108.         }
  1109.     break;
  1110.     case GID_10_CB8:
  1111.         if (!(GetAttr
  1112.         (   GA_Selected, files_gadgets[GID_10_CB8], (ULONG *) &files.show[7]
  1113.         )))
  1114.         {   rq("Unsupported inquiry!"); // should never happen
  1115.         }
  1116.     break;
  1117.     case GID_10_ST1:
  1118.         if (!(GetAttr
  1119.         (   STRINGA_TextVal, files_gadgets[GID_10_ST1], (ULONG *) &stringptr
  1120.         )))
  1121.         {   rq("Unsupported inquiry!"); // should never happen
  1122.         }
  1123.         strcpy(shared.output, stringptr);
  1124.     break;
  1125.     case GID_10_BU1:
  1126.         if (asl("~(#?.info)"))
  1127.         {   strcpy(shared.pathname, aslresult);
  1128.             SetGadgetAttrs
  1129.             (   files_gadgets[GID_10_ST1], MainWindowPtr, NULL,
  1130.                 STRINGA_TextVal, shared.pathname,
  1131.                 TAG_END
  1132.            );
  1133.         }
  1134.     break;
  1135.     case GID_10_BU2:
  1136.         updatefiles();
  1137.     break;
  1138.     case GID_10_BU4:
  1139.         page = 0;
  1140.     break;
  1141.     case GID_10_CB9:
  1142.         if (!(GetAttr
  1143.         (   GA_Selected, files_gadgets[GID_10_CB9], &shared.log
  1144.         )))
  1145.         {   rq("Unsupported inquiry!"); // should never happen
  1146.         }
  1147.         files_updatelog();
  1148.         if (shared.log)
  1149.         {   ActivateLayoutGadget(files_gadgets[GID_10_LY1], MainWindowPtr, NULL, (Object) files_gadgets[GID_10_ST1]);
  1150.         }
  1151.     break;
  1152.     default:
  1153.     break;
  1154. }   }
  1155.  
  1156. AGLOBAL ULONG Hook10Func(struct Hook *h, VOID *o, VOID *msg)
  1157. {   /* "When the hook is called, the data argument points to the 
  1158.     window object and message argument to the IntuiMessage." */
  1159.  
  1160.     UWORD code, qual;
  1161.     ULONG scroll;
  1162.  
  1163.     geta4(); // wait till here before doing anything
  1164.  
  1165.     code = ((struct IntuiMessage *) msg)->Code;
  1166.     qual = ((struct IntuiMessage *) msg)->Qualifier;
  1167.  
  1168.     switch(code)
  1169.     {
  1170.     case SCAN_HELP:
  1171.         if (status == STATUS_READY)
  1172.         {   helpabout();
  1173.         }
  1174.     break;
  1175.     case SCAN_ESCAPE:
  1176.         if (status == STATUS_READY)
  1177.         {   if ((qual & IEQUALIFIER_LSHIFT) || (qual & IEQUALIFIER_RSHIFT))
  1178.             {   cleanexit(EXIT_SUCCESS);
  1179.             } else page = 0;
  1180.         } else
  1181.         {   // assert(status == STATUS_BUSY);
  1182.             status = STATUS_STOPPING;
  1183.         }
  1184.     break;
  1185.     case SCAN_V:
  1186.         if (status == STATUS_READY)
  1187.         {   if (!(qual & IEQUALIFIER_LSHIFT) && !(qual & IEQUALIFIER_RSHIFT))
  1188.             {   if (files.osversion < OSOPTIONS)
  1189.                     files.osversion++;
  1190.                 else files.osversion = 0;
  1191.             } else
  1192.             {   if (files.osversion > 0)
  1193.                     files.osversion--;
  1194.                 else files.osversion = OSOPTIONS;
  1195.             }
  1196.             SetGadgetAttrs
  1197.             (   files_gadgets[GID_10_CH1], MainWindowPtr, NULL,
  1198.                 CHOOSER_Selected, files.osversion,
  1199.                 TAG_END
  1200.             );
  1201.         }
  1202.     break;
  1203.     case SCAN_UP:
  1204.         if (qual & IEQUALIFIER_CONTROL)
  1205.         {   scroll = LBP_TOP;
  1206.         } elif (qual & IEQUALIFIER_LSHIFT || qual & IEQUALIFIER_RSHIFT)
  1207.         {   scroll = LBP_PAGEUP;
  1208.         } else scroll = LBP_LINEUP;
  1209.     break;
  1210.     case SCAN_DOWN:
  1211.         if (qual & IEQUALIFIER_CONTROL)
  1212.         {   scroll = LBP_BOTTOM;
  1213.         } elif (qual & IEQUALIFIER_LSHIFT || qual & IEQUALIFIER_RSHIFT)
  1214.         {   scroll = LBP_PAGEDOWN;
  1215.         } else scroll = LBP_LINEDOWN;
  1216.     break;
  1217.     default:
  1218.     break;
  1219.     }
  1220.  
  1221.     if (code == SCAN_UP || code == SCAN_DOWN)
  1222.     {   SetGadgetAttrs
  1223.         (   files_gadgets[GID_10_LB1],    // pointer to gadget
  1224.             MainWindowPtr,                // pointer to window (not window object!)
  1225.             NULL,                         // pointer to requester
  1226.             LISTBROWSER_Position, scroll, // tags
  1227.             TAG_DONE                      // done
  1228.         );
  1229.     }
  1230.  
  1231.     return(1);
  1232. }
  1233.  
  1234. MODULE void stopping(STRPTR status)
  1235. {   SetGadgetAttrs // `Status'
  1236.     (   files_gadgets[GID_10_ST2], MainWindowPtr, NULL,
  1237.         STRINGA_TextVal, status,
  1238.         TAG_END
  1239.     );
  1240.     SetGadgetAttrs // `Stop'
  1241.     (   files_gadgets[GID_10_BU3], MainWindowPtr, NULL,
  1242.         GA_Disabled, TRUE,
  1243.         TAG_END
  1244.     );
  1245. }
  1246.  
  1247. MODULE void files_updatelog(void)
  1248. {   BOOL inverse;
  1249.  
  1250.     if (shared.log)
  1251.     {   inverse = FALSE;
  1252.     } else
  1253.     {   inverse = TRUE;
  1254.     }
  1255.  
  1256.     SetGadgetAttrs // `Log to file:' (string)
  1257.     (   files_gadgets[GID_10_ST1], MainWindowPtr, NULL,
  1258.         GA_Disabled, inverse,
  1259.         TAG_END
  1260.     );
  1261.     /* For some reason, we need to explicitly refresh the string gadget
  1262.     visuals here */
  1263.     RefreshGadgets((struct Gadget *) files_gadgets[GID_10_ST1], MainWindowPtr, NULL);
  1264.  
  1265.     SetGadgetAttrs // `Log to file:' (ASL button)
  1266.     (   files_gadgets[GID_10_BU1], MainWindowPtr, NULL,
  1267.         GA_Disabled, inverse,
  1268.         TAG_END
  1269.     );
  1270. }
  1271.  
  1272.